from fastapi import FastAPI, UploadFile, File, HTTPException
from typing import Dict

app = FastAPI(title="Speech-to-Text (STT) Service")

@app.post("/stt", response_model=Dict)
async def speech_to_text(audio_file: UploadFile = File(...)):
    """
    接收音频文件并返回转录的文本。
    该端点将调用百度STT客户端。
    """
    # 占位逻辑
    # 在实际实现中，你将在这里调用百度客户端。
    # text = await baidu_client.transcribe(audio_file.file)
    
    # 目前，返回一个模拟响应
    if not audio_file.filename:
        raise HTTPException(status_code=400, detail="No file uploaded")

    return {"text": "这是识别出的语音文本"}

@app.get("/")
def read_root():
    return {"message": "STT Service is running"} 